<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //合并对象
        var a = { a: 1, b: 2, d: 5 };
		var b = { a: 2, b: 3, c: 4 };
        //es6.object.assign(对象1,对象2)
      /*   console.log(Object.assign(a,b));
        let c=Object.assign({}.a,b)
        console.log(c);  */

       /*  //传统
        for (let key in b){
            a[key]=b[key]
        }
        console.log(a); */
   
    
        function a(obj) {
            let b = null;
            if (typeof obj == 'object' && obj !== null) {
                b = obj instanceof Array ? [] : {};
                for (let i in obj) {
                    b[i] = a([obj[i]])
                }
            } else {
                b = obj
            }
            return b
        }
  
    </script>
</body>
</html>